package com.self.starter.config;

import com.self.starter.pojo.UserClient;
import com.self.starter.properties.SelfProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动构建UserClient实例
 */
@Configuration
@EnableConfigurationProperties(SelfProperties.class)
public class SelfAutoConfigure {
    @Bean
    @ConditionalOnProperty(prefix = "spring.self.props", value = "enabled", havingValue = "true")
    public UserClient userClient(SelfProperties selfProperties) {
        return new UserClient(selfProperties);
    }
}
